package com.cy.pj.sys.web.controller;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.sys.pojo.SysMenu;
import com.cy.pj.sys.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 创建SysMenuController类型，通过此对象处理客户端请求
 *
 *
 */
@RequestMapping ("/menu")
@RestController
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;

    @GetMapping("{id}")
    public JsonResult doFindById(@PathVariable Integer id){
        return new JsonResult(sysMenuService.findById(id));
    }
    @PutMapping
    public JsonResult doUpdateMenus(SysMenu menu){
        sysMenuService.updateMenu(menu);
        return  new JsonResult("update ok");
    }

    @PostMapping
    public JsonResult doSaveMenu(
            @RequestBody SysMenu menu){
        sysMenuService.saveMenu(menu);
        return new JsonResult("Save OK");
    }

    @GetMapping
    public JsonResult doFindMenus(){
        return new JsonResult(sysMenuService.findMenus());
    }

    @GetMapping("treeNodes")
    public JsonResult doFindMenuTreeNodes(){
        return new JsonResult(
                sysMenuService.findMenuTreeNodes());
    }



}










